home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 25
/
Volume 25 - JOGO DISK .iso
/
Games
/
elementalgame.swf
/
scripts
/
frame_5
/
DoAction.as
Wrap
Text File
|
2006-08-22
|
5KB
|
198 lines
function moveHero()
{
hitground = map_mc.hitTest(hero_mc._x,hero_mc._y,true);
hitroof = map_mc.hitTest(hero_mc._x,hero_mc._y - 30,true);
if(isAlive)
{
if(keyright)
{
hero_mc.gotoAndStop("runright");
hori = 5;
}
else if(_root.keyleft)
{
hero_mc.gotoAndStop("runleft");
hori = -5;
}
else if(hori > 0)
{
hori -= 1;
}
else if(hori < 0)
{
hori += 1;
}
else if(hori == 0)
{
hero_mc.gotoAndStop("stand");
}
if(keydown)
{
hero_mc.gotoAndStop("down");
hori = 0;
}
}
if(!hitground)
{
vert += 1;
if(vert > 0)
{
if(map_mc.hitTest(hero_mc._x,hero_mc._y + 2,true))
{
hero_mc._y += 2;
vert = 0;
}
else if(map_mc.hitTest(hero_mc._x,hero_mc._y + 4,true))
{
hero_mc._y += 4;
vert = 0;
}
else if(map_mc.hitTest(hero_mc._x,hero_mc._y + 6,true))
{
hero_mc._y += 6;
vert = 0;
}
else if(map_mc.hitTest(hero_mc._x,hero_mc._y + 8,true))
{
hero_mc._y += 8;
vert = 0;
}
else if(map_mc.hitTest(hero_mc._x,hero_mc._y + 10,true))
{
hero_mc._y += 10;
vert = 0;
}
}
else if(vert < 0 && isAlive)
{
if(map_mc.hitTest(hero_mc._x,hero_mc._y - 32,true))
{
hero_mc._y += 2;
vert = 0;
}
else if(map_mc.hitTest(hero_mc._x,hero_mc._y - 34,true))
{
hero_mc._y += 4;
vert = 0;
}
else if(map_mc.hitTest(hero_mc._x,hero_mc._y - 36,true))
{
hero_mc._y += 6;
vert = 0;
}
else if(map_mc.hitTest(hero_mc._x,hero_mc._y - 38,true))
{
hero_mc._y += 8;
vert = 0;
}
else if(map_mc.hitTest(hero_mc._x,hero_mc._y - 40,true))
{
hero_mc._y += 10;
vert = 0;
}
}
}
hitground = map_mc.hitTest(hero_mc._x,hero_mc._y,true);
if(hitground)
{
vert = 0;
if(keyspace && isAlive && !hitroof)
{
hero_mc.gotoAndStop("jump");
vert = -8;
}
if(map_mc.hitTest(hero_mc._x,hero_mc._y - 10,true))
{
hero_mc._y -= 10;
}
else if(map_mc.hitTest(hero_mc._x,hero_mc._y - 8,true))
{
hero_mc._y -= 8;
}
else if(map_mc.hitTest(hero_mc._x,hero_mc._y - 6,true))
{
hero_mc._y -= 6;
}
else if(map_mc.hitTest(hero_mc._x,hero_mc._y - 4,true))
{
hero_mc._y -= 4;
}
else if(map_mc.hitTest(hero_mc._x,hero_mc._y - 2,true))
{
hero_mc._y -= 2;
}
}
hero_mc.oldx = hero_mc._x;
hero_mc._y += vert * msdiff;
hero_mc._x += hori * msdiff;
if(map_mc.hitTest(hero_mc._x + 4,hero_mc._y - 5,true))
{
hori -= 1;
}
if(map_mc.hitTest(hero_mc._x - 4,hero_mc._y - 5,true))
{
hori += 1;
}
if(map_mc.hitTest(hero_mc._x + hori,hero_mc._y - 20,true))
{
hero_mc._x += hero_mc.oldx - hero_mc._x;
hori = 0;
hero_mc.gotoAndStop(1);
}
}
function moveWorld()
{
if(hero_mc._x > 500)
{
diff = 500 - hero_mc._x;
map_mc._x += diff;
details_mc._x += diff;
bullets._x += diff;
hero_mc._x += diff;
}
else if(hero_mc._x < 0)
{
diff = - hero_mc._x;
map_mc._x += diff;
details_mc._x += diff;
bullets._x += diff;
hero_mc._x += diff;
}
}
function killHero()
{
}
stop();
Stage.scaleMode = "noScale";
Stage.showMenu = false;
var now = getTimer();
var then = now;
var msdiff = 0;
var points = 0;
var xscale = hero_mc._xscale;
var vert = 0;
var hori = 0;
var hitground = false;
var hitroof = false;
var isAlive = true;
step1 = false;
step2 = false;
lives = 3;
points = 0;
_root.hero_mc._y = 280;
_root.hero_mc._x = 50;
_root.health_mc.gotoAndStop(1);
_root.back.gotoAndPlay("end");
onEnterFrame = function()
{
then = now;
now = getTimer();
msdiff = (now - then) / 26;
keyleft = Key.isDown(37) || Key.isDown(65);
keyright = Key.isDown(39) || Key.isDown(68);
keyspace = Key.isDown(38) || Key.isDown(87) || Key.isDown(32);
keydown = Key.isDown(40) || Key.isDown(83);
moveHero();
moveWorld();
};